<html><head>
    <meta charset="utf-8">
    <title>权限管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <link rel="stylesheet" href="/layuiAdmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiAdmin/css/admin.css" media="all">
<body layadmin-themealias="default">

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header">编辑</div>
        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" action="" >
                <div class="layui-form-item">
                    <label class="layui-form-label">名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入名称" class="layui-input" value="{{$res['name']}}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">权限</label>
                    <div class="layui-input-block">
                        <input type="text" name="auth" lay-verify="" placeholder="请输入权限" autocomplete="off" class="layui-input" value="{{$res['auth']}}">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">归属</label>
                    <div class="layui-input-block">
                        <select name="pid" lay-filter="aihao">
                            <option value="0">权限模块</option>
                            @foreach ($auths as $auth)
                                <option value="{{$auth['id']}}"{{$res['pid'] == $auth['id'] ? 'selected' : ''}} {{$auth['disabled'] || $auth['id'] == $id ? 'disabled' : ''}}>{{str_repeat("┝",$auth['level'])}}{{$auth['name']}}</option>
                            @endforeach
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">sort</label>
                    <div class="layui-input-inline">
                        <input type="text" name="sort" lay-verify="" autocomplete="off" placeholder="sort" class="layui-input" value="{{$res['sort']}}">
                    </div>
                </div>

                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        <button type="button" class="layui-btn layui-btn-primary" onclick="location.href='/admin/auth'">返回列表</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script src="/layuiAdmin/layui/layui.js"></script>
<script src="/layuiAdmin/tool.js"></script>

<script>
    var id = {{$id}};
    layui.use(['form'], function() {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.jquery;

        /*$.get('/admin/menu/find/' + id, function (rJson) {
            if(rJson.status){
                form.val("formEdit", rJson.data);
            }else {
                layer.msg(rJson.msg, {time: 5000, icon:5});
            }

        });*/

        form.on('submit(demo1)', function(data) {
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });

            $.post('/admin/auth/edit/' + id , data.field , function (rJson) {

                if(rJson.status){
                    successAlert(rJson.msg);
                }else{
                    layer.msg(rJson.msg, {time: 5000, icon:5});
                }
            });
            return false;
        });


    });
</script>


</body>
</html>
